<template>
  <div class="app-container">
    <el_row>

      <el-col :span="12" class="card-box">
        <el-card>
          <div slot="header"><span>订单录入</span></div>
          <div class="el-table el-table--enable-row-hover el-table--medium " style="height: 800px">
            <el-form ref="form" :model="form" :rules="rules" label-width="70px">
              <el-form-item label="订单ID"  prop="orderId">
                <el-input v-model="form.orderId" placeholder="请输入订单ID"  :disabled="true"/>
              </el-form-item>
              <el-form-item label="客户姓名" prop="clientName">
                <el-input v-model="form.clientName" placeholder="请输入客户姓名" />
              </el-form-item>
              <el-form-item label="客户电话" prop="clientPhone">
                <el-input v-model="form.clientPhone" placeholder="请输入客户电话" />
              </el-form-item>
              <el-form-item label="交付日期" prop="dateReleased">
                <el-date-picker clearable size="small"
                                v-model="form.dateReleased"
                                type="date"
                                value-format="yyyy-MM-dd"
                                placeholder="选择交付日期">
                </el-date-picker>
              </el-form-item>
              <el-form-item label="录入时间" prop="inputime">
                <el-date-picker clearable size="small"
                                v-model="form.inputime"
                                type="datetime"
                                value-format="yyyy-MM-dd HH:mm:ss"
                                placeholder="选择录入时间">
                </el-date-picker>
              </el-form-item>
              <el-form-item label="技术交底人" prop="dataPreprocessor">
                <el-select v-model="form.dataPreprocessor">
                  <el-option
                    v-for="dict in dict.type.sys_cme_technicalhandover"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  />
                </el-select>
              </el-form-item>
              <el-form-item label="录入人员" prop="salesman">
                <el-select v-model="form.salesman">
                  <el-option
                    v-for="dict in dict.type.sys_cme_ordermen"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  />
                </el-select>
              </el-form-item>
              <el-form-item label="技术要求" prop="technicalRequirements">
                <el-input v-model="form.technicalRequirements" type="textarea" placeholder="请输入内容" />
              </el-form-item>
              <el-form-item label="上传">
                <!--<file-upload/>-->
                <file-upload :orderid="form.orderId"  />
              </el-form-item>
              <el-form-item label="下载">
                <el-link   :underline="false">
                  <el-button type="primary" @click="getorderfile">获取文件<i class="el-icon-download el-icon--right"></i></el-button>
                </el-link>
              </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
              <el-button type="primary" @click="submitForm">提交</el-button>
              <el-button @click="cancel">取 消</el-button>
            </div>
          </div>
        </el-card>
      </el-col>



      <el-col :span="12" class="card-box">
        <el-card>
          <div slot="header"><span>熔覆过程</span></div>
          <div class="el-table el-table--enable-row-hover el-table--medium " style="height: 800px">
                <el-form ref="form" :model="claddingprocess" :rules="rules" label-width="80px">
                  <el-form-item label="订单ID" prop="orderId">
                    <el-input v-model="claddingprocess.orderId" placeholder="请输入订单ID"  :disabled="true"/>
                  </el-form-item>
                  <el-form-item label="熔覆人员">
                    <el-radio-group v-model="claddingprocess.claddingPeople">
                      <el-radio
                        v-for="dict in dict.type.zs_cladding_people"
                        :key="dict.value"
                        :label="dict.value"
                      >{{dict.label}}</el-radio>
                    </el-radio-group>
                  </el-form-item>
                  <el-form-item label="熔覆名称" prop="claddingName">
                    <el-input v-model="claddingprocess.claddingName" placeholder="请输入熔覆名称" />
                  </el-form-item>
                  <el-form-item label="熔覆工艺" prop="claddingTech">
                    <el-input v-model="claddingprocess.claddingTech" type="textarea" placeholder="请输入内容" />
                  </el-form-item>
                  <el-form-item label="设备状态">
                    <el-radio-group v-model="claddingprocess.deviceStatus">
                      <el-radio
                        v-for="dict in dict.type.sys_device_status"
                        :key="dict.value"
                        :label="parseInt(dict.value)"
                      >{{dict.label}}</el-radio>
                    </el-radio-group>
                  </el-form-item>
                  <el-form-item label="质检记录" prop="qualityRecord">
                    <el-input v-model="claddingprocess.qualityRecord" type="textarea" placeholder="请输入内容" />
                  </el-form-item>
                  <el-form-item label="是否处理">
                    <el-radio-group v-model="claddingprocess.isHandle">
                      <el-radio
                        v-for="dict in dict.type.zs_cladding_ishandle"
                        :key="dict.value"
                        :label="parseInt(dict.value)"
                      >{{dict.label}}</el-radio>
                    </el-radio-group>
                  </el-form-item>
<!--                  <el-form-item label="是否合格">-->
<!--                    <el-radio-group v-model="claddingprocess.isqualitified">-->
<!--                      <el-radio-->
<!--                        v-for="dict in dict.type.sys_quality_result"-->
<!--                        :key="dict.value"-->
<!--                        :label="parseInt(dict.value)"-->
<!--                      >{{dict.label}}</el-radio>-->
<!--                    </el-radio-group>-->
<!--                  </el-form-item>-->
                  <el-form-item label="异常记录" prop="unnormalRecord">
                    <el-input v-model="claddingprocess.unnormalRecord" type="textarea" placeholder="请输入内容" />
                  </el-form-item>
              <el-form-item label="上传">
                <!--<file-upload/>-->
                <cladding-process :orderid="claddingprocess.orderId"  />
              </el-form-item>
              <el-form-item label="下载">
                <el-link   :underline="false">
                  <el-button type="primary" @click="getcladdingprocessfile">获取文件<i class="el-icon-download el-icon--right"></i></el-button>
                </el-link>
              </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
              <el-button type="primary" @click="submitcladdingprocess">提交</el-button>
              <el-button @click="cancel">取 消</el-button>
            </div>
          </div>
        </el-card>
      </el-col>
    </el_row>
    </div>
</template>

<script>

import {listCmelasercladding,getCmelasercladding,delCmelasercladding,addCmelasercladding,updateCmelasercladding} from "@/api/cmelasercladding/cmelasercladding";
import {listLaserCladdingOrder,getLaserCladdingOrder,delLaserCladdingOrder,addLaserCladdingOrder,updateLaserCladdingOrder} from "@/api/LaserCladding/LaserCladdingOrder"
import {listCmelasercladding1, getFileInformation} from "@/api/cmelasercladding/claddingurl"
import {download} from '@/utils/request';
import ElFormItem from "element-ui/packages/form/src/form-item";
import CladdingProcess from "@/views/cmelasercladding/file/CladdingProcess";
import FileUpload from "@/views/cmelasercladding/file/FileUpload"

export default {
  name: "cmelasercladdingdetail",
  dicts: ['sys_cme_technicalhandover','sys_cme_ordermen','zs_cladding_people','sys_device_status','zs_cladding_ishandle','sys_quality_result'],
  components: {
    ElFormItem,
    FileUpload,
    CladdingProcess,
  },
  data() {
    return {
      // 遮罩层
      loading: true,

      // 表单参数
      form: {},
      preprocess:{},
      urlList:{
      },
      //order文件名
      orderfilename: null,
      predatafilename:null,
      claddingprocess:{},
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        orderId: null,
        oederid: null,
        resource:  "http://localhost:8080/profile/upload/2022/01/17/ac411ff8-3d86-44c4-9093-241560962f56.zip",
      },
      // whatfile: 111110
    };
  },
  created() {
    this.getList();
  },
  mounted() {

  },
  methods: {

    getList() {
      this.loading = true;
      //获取路由跳转时的传参
      let orderid = this.$route.query.orderid
      this.queryParams.orderId = orderid;
      this.queryParams.oederid = orderid;
      //获取熔覆处理数据
      listCmelasercladding(this.addDateRange(this.queryParams)).then(response => {
        this.claddingprocess = response.rows[0];
      });

      //获取url原始数据
      listCmelasercladding1(this.queryParams).then(response => {
        this.urlList = response.rows[0];
        console.log(this.urlList.claddingUpload);
        console.log(this.urlList.claddingprocessUpload);
      });
      //获取熔覆处理订单原始数据
      listLaserCladdingOrder(this.queryParams).then(response => {
        this.form = response.rows[0];
      });
      //获取文件信息
      getFileInformation(this.queryParams).then(response => {
        this.orderfilename = response.orderfilename;
       this.predatafilename=response.predatafilename
      });
      this.loading = false;
    },

    //order文件下载
    getorderfile(){
      this.queryParams.resource = this.urlList.claddingUpload;
      console.log(this.queryParams.resource);
      download("/cmelasercladding/download/resource", this.queryParams, "激光熔覆原始文件：" + this.queryParams.orderId + this.orderfilename);
    },
    //claddingprocess文件下载
    getcladdingprocessfile(){
      this.queryParams.resource = this.urlList.claddingprocessUpload;
      console.log(this.queryParams.resource);
      download("/cmelasercladding/download/resource", this.queryParams, "熔覆处理文件:"+this.queryParams.orderId + this.predatafilename);
    },
    /** 提交修改order按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          updateLaserCladdingOrder(this.form).then(response => {
            this.$modal.msgSuccess("修改订单信息成功");
            this.open = false;
            this.getList();
          });
        }
      });
    },

    //**提交修改claddingprocess按钮*/
    submitcladdingprocess() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          updateCmelasercladding(this.claddingprocess).then(response => {
            this.$modal.msgSuccess("修改熔覆处理信息成功");
            this.open = false;
            this.getList();
          });
        }
      });
    },

  }
}
</script>

<style scoped>
.dialog-footer {
  float: right
}
</style>
